﻿using System.Web;

namespace BestEasyCMS.Framework.SessionStorage
{
    public class SessionStorageService : ISessionStorageService
    {
        /// <summary>
        /// 添加一个Session
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        /// <param name="timeOut">过期时间/分钟[默认20分钟]</param>
        public void SetSession(string key, object value, int timeOut = 20)
        {
            HttpContext.Current.Session.Timeout = timeOut;
            HttpContext.Current.Session[key] = value;
        }
        /// <summary>
        /// 获取一个Session
        /// </summary>
        /// <param name="key">键</param>
        /// <returns></returns>
        public object GetSession(string key)
        {
            return HttpContext.Current.Session[key];
        }
    }
}
